<?php

// 首页
class IndexAction extends Action {

	 public function index()
    {
		
		
		if(isset($_GET['aid'])){
			$aid = intval($_GET['aid']);
			$_SESSION['aid'] = $aid;
		}else{
			if(isset($_SESSION['aid'])) $aid = $_SESSION['aid'];
			else $aid=0;
		}

		//获取站点名称
		if(!empty($_SESSION['area'])){
			//$area = $_SESSION['area'];
			$area = getAreaName($aid);
		}else{
			$area = getAreaName($aid);
		}

		//获取顶部广告
		$m = M('advert');	  
		$map=array('status'=>1);
		//if($aid) $map['aid']=$aid;
		$advlist = $m->where($map)->limit(10)->select();
		
		//获取推荐商家
		$m= M('Businesses');
		$map=array('status'=>1,'recommend'=>1);
		if($aid) $map['aid']=$aid;
		$ord=array('create_time'=>'desc');
		$business_list = $m->where($map)->order($ord)->limit(8)->select();
		//echo $m->getLastSql();

		//获取推荐生活信息
		$m= M('Info');
		$map=array('status'=>1);
		if($aid) $map['aid']=$aid;
		$ord=array('create_time'=>'desc');
		$info_tuijian = $m->where($map)->order($ord)->limit(8)->select();
		//echo $m->getLastSql();
		

		$this->assign('aid',$aid);
		$this->assign('area',$area);
		$this->assign('advlist',$advlist);
		$this->assign('business_list',$business_list);
		$this->assign('info_tuijian ',$info_tuijian);
        $this->display();
    }

}

